# python module

def xpermutations(items):
    """yield all combinatorical permutations of alements of a list"""
    return xcombinations(items, len(items))

def xcombinations(items, n):
    """yield all combinatorical n-combinations of a list"""
    if n==0: yield []
    for i in range(len(items)):
        for cc in xcombinations(items[:i]+items[i+1:],n-1):
            yield [items[i]]+cc

###

def splitby(predicate, iterable):
    """return a tuple of lists (trues, falses) with prticate applied to every element of the input list."""
    trues = []
    falses = []
    for i in iterable:
        if predicate(i):
            trues.append(i)
        else:
            falses.append(i)
    return trues, falses
